package com.lh.principle.inversion.improve;

public class DependecyInversion {
	public static void main(String[] args) {

		//客户端无需改变
		Person person = new Person();
		person.receive(new Email());

		person.receive(new Weixin());

	}
}


//定义一个接口
interface Ireceiver{

	String getInfo();

}


class Email implements Ireceiver{

	@Override
	public String getInfo() {
		return "电子邮件信息：hello,world";
	}

}

//增加微信接受
//只需要实现下接口即可
class Weixin implements Ireceiver{
	@Override
	public String getInfo() {
		return "微信信息：hello,world";
	}
}



//方式2
class Person{

	//对接口的一个依赖,接口不能实例化，只需要实例化对应的实现即可
	public void receive(Ireceiver receiver) {
		System.out.println(receiver.getInfo());
	}
}


